package com.nbsaas.boot.script.data.entity;


import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.rest.filter.Operator;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.util.Date;

@ComposeView
@Comment("查询模板")
@Data
@FormAnnotation(title = "查询模板")
@Entity
@Table(name = "sys_common_query_template")
public class ScriptTemplate {

    @SearchItem(label = "模板代码", name = "id", operator = Operator.like, show = false)
    @FormField(title = "模板代码", grid = true, width = "160", col = 22, required = true)
    @Comment("主键id")
    @Id
    @Column(length = 50, unique = true)
    private String id;


    @FormField(title = "模板名称", grid = true, width = "400", col = 22, required = true)
    @SearchItem(label = "模板名称", name = "name")
    @Comment("模板名称")
    String name;


    @FormField(title = "java映射类", col = 22)
    private String className;


    @Lob
    @NoSimple
    @FormField(title = "模板内容", width = "400", col = 22)
    @Comment("模板内容")
    String content;

    /**
     *
     */
    @SearchItem(label = "查询类型", name = "queryType", operator = Operator.eq, classType = Integer.class, show = false)
    @Comment("查询类型")
    @Dict(items = {
            @DictItem(value = 1, label = "分页"),
            @DictItem(value = 2, label = "报表"),
            @DictItem(value = 3, label = "批量查询"),
            @DictItem(value = 4, label = "待办")
    })
    private Integer queryType;


    @Dict(items = {
            @DictItem(value = 1, label = "进行预处理"),
            @DictItem(value = 2, label = "不预处理")
    })
    private Integer preType;




    @Comment("是否企业数据汇总，列表同时查询，搜索的时候第一页查询,前端判断是否进行汇总查询")
    @Dict(
            items = {
                    @DictItem(value = 1, label = "汇总"),
                    @DictItem(value = 2, label = "不汇总")
            }
    )
    private Integer summaryType;

    @Column(length = 100)
    @Comment("数据汇总查询模型")
    private String summaryModel;


    @Comment("是否可以跳转")
    @Dict(
            items = {
                    @DictItem(value = 1, label = "行跳转"),
                    @DictItem(value = 2, label = "列跳转"),
                    @DictItem(value = 3, label = "不跳转")
            }
    )
    private Integer jumpType;

    @Comment("跳转地址")
    private String jumpUrl;


    @Comment("移动端样式")
    private Integer headerStyle;


    @Comment("日期范围 1当天 2最近七天 3本周  4本月")
    private Integer dateRange;


    @Comment("缓存模式 计算请求参数md5，作为缓存键")
    private Integer cacheModel;

    @Column(length = 100)
    @Comment("存储过程")
    private String storeProcedure;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "公共查询"),
                    @DictItem(value = 2, label = "私有查询")

            }
    )
    @FormField(title = "模板类型", grid = true, col = 22)
    @SearchItem(label = "模板类型", name = "type", operator = Operator.eq, classType = Integer.class, show = false)
    @Comment("模板类型")
    Integer type;

    @Dict(items = {
            @DictItem(value = 1, label = "调试模式"),
            @DictItem(value = 2, label = "运行模式")
    })
    @FormField(title = "调试模式", grid = true, col = 22)
    @Comment("调试模式")
    private Integer debugMode;


    @Dict(
            items = {
                    @DictItem(value = 1, label = "限制"),
                    @DictItem(value = 2, label = "不限制")
            }
    )
    @Comment("访问日期限制")
    private Integer dateLimit;

    @Column(length = 50)
    @Comment("日期限制字段")
    private String dateLimitField;


    @Comment("权限")
    private String permission;


    @Comment("查询结果是否处理 1处理 2不处理")
    private Integer resultHandleType;


    @Column(length = 1000)
    @FormField(title = "模板描述", grid = true, width = "200000", col = 22, type = InputType.textarea)
    @Comment("模板描述")
    String note;


    @Comment("创建人id")
    private Long creatorId;


    @Comment("修改人id")
    private Long modifierId;


    @FormField(title = "添加时间", grid = true, width = "160", ignore = true)
    @Comment("添加时间")
    private Date addDate;

    @Comment("最新修改时间")
    private Date lastDate;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "部分数据"),
                    @DictItem(value = 2, label = "全部数据")

            }
    )
    @Comment("数据范围控制1")
    private Integer dataScope1;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "部分数据"),
                    @DictItem(value = 2, label = "全部数据")
            }
    )
    @Comment("数据范围控制2")
    private Integer dataScope2;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "部分数据"),
                    @DictItem(value = 2, label = "全部数据")
            }
    )
    @Comment("数据范围控制3")
    private Integer dataScope3;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "部分数据"),
                    @DictItem(value = 2, label = "全部数据")
            }
    )
    @Comment("数据范围控制4")
    private Integer dataScope4;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "部分数据"),
                    @DictItem(value = 2, label = "全部数据")
            }
    )
    @Comment("数据范围控制5")
    private Integer dataScope5;

    @Dict(
            items = {
                    @DictItem(value = 1, label = "部分数据"),
                    @DictItem(value = 2, label = "全部数据")
            }
    )
    @Comment("数据范围控制6")
    private Integer dataScope6;

    @Comment("是否是慢查询 1是 2不是")
    private Integer slowQuery;

}
